<template>
	<view class="box">
		<view class="item">
			<text>手机号</text>
			<input type="text" v-model="mobile" disabled placeholder="请输入手机号"/>
		</view>
		<!-- <view class="item">
			<text>验证码</text>
			<view class="indenty">
				<input type="text" value="" placeholder="请输入验证码"/>
				<view class="getindenty">
					获取验证码
				</view>
			</view>
		</view> -->
		<view class="item">
			<text>新密码</text>
			<input type="password" v-model="pwd1" placeholder="请输入新密码"/>
		</view>
		<view class="item">
			<text>确认密码</text>
			<input type="password" v-model="pwd2" placeholder="再次确认密码"/>
		</view>
		
		<view class="sure" @click="updatepassword">
			确定
		</view>
	</view>
</template>

<script>
	import {
		changepass
	} from "../../apis/shop/api.js"
	export default{
		data(){
			return{
				store_id:"",
				token:"",
				mobile:"",
				password:""
			}
		},
		onLoad(option) {
			this.mobile = option.phone
			this.store_id = uni.getStorageSync("store_id");
			this.token = uni.getStorageSync("token");
		},
		methods:{
			updatepassword(){
				let that = this
				if(that.pwd1 === that.pwd2){
					that.password = that.pwd1
					changepass({
						store_id:that.store_id,
						token:that.token,
						mobile:that.mobile,
						password:that.password
					}).then(res=>{
						if(res.code == 1){
							uni.showToast({
								title:"修改成功"
							})
							uni.navigateTo({
								url:"/pages/shopmanager/setting"
							})
						}
						else{
							uni.showToast({
								title:res.msg,
								icon:"none"
							})
						}
					})
				}
				else{
					uni.showToast({
						title:"两次密码不一致",
						icon:"none"
					})
				}
			}
		}
	}
</script>

<style lang="less">
.box{
	padding:  0 30rpx;
	.item{
		display: flex;
		border-bottom:1rpx solid #C7BEBE ;
		
		text{
			display: block;
			width: 180rpx;
			line-height: 88rpx;
			font-size: 30rpx;
			color: #333;
		}
		input{
			flex: 1;
			height: 88rpx;
			line-height: 88rpx;
			font-size: 30rpx;
		}
		.indenty{
			display: flex;
			.getindenty{
				width: 176rpx;
				height: 48rpx;
				margin-top: 20rpx;
				background-color: #E41805;
				color: #fff;
				line-height: 48rpx;
				font-size: 26rpx;
				text-align: center;border-radius: 10rpx;
			}
		}
	}
	.sure{
		height: 88rpx;
		line-height: 88rpx;
		margin-top: 40rpx;
		background-color: #E41805;
		color: #fff;
		text-align: center;
		border-radius: 10rpx;
	}
}	
</style>
